public class Application{
    public static void main(String[] args) {
        Simulator simulator = new Simulator();

        simulator.playSound(new Dog());

        simulator.playSound(new Cat());
    }
}


 abstract class Animal {
    public abstract void cry();
    public abstract String getAnimalName();


}
class Dog extends Animal{


    @Override
    public void cry() {
        System.out.println("旺旺！");
    }

    @Override
    public String getAnimalName() {
        return "Dog";
    }
}
class Cat extends Animal{

    @Override
    public void cry() {
        System.out.println("喵喵");
    }

    @Override
    public String getAnimalName() {
        return "猫";
    }
}

class  Simulator{
    public  void playSound(Animal animal){
        animal.cry();
        System.out.println(animal.getAnimalName());
    }
}
